//
//  MTLiveInputPasswordView.m
//  MeToo
//
//  Created by 俊松何 on 2018/7/20.
//  Copyright © 2018年 tianxie. All rights reserved.
//

#import "MTLiveInputPasswordView.h"
#import "MTInputPasswordView.h"

@interface MTLiveInputPasswordView  ()


@property(nonatomic,strong) UILabel *titleLable;

@property(nonatomic,strong) KLCPopup *pop;
@end

@implementation MTLiveInputPasswordView



+(instancetype)liveinputPasswordView
{
    MTLiveInputPasswordView *view = [[MTLiveInputPasswordView alloc] initWithFrame:CGRectMake(0, 0, WIDTH - 30, 120)];
    view.layer.masksToBounds = YES;
    view.layer.cornerRadius = 8;
    return view;
}


//-(void)setCompleteBlock:(void (^)(NSString *))completeBlock
//{
//    _passwordView.completeBlock = completeBlock;
//}

-(instancetype)initWithFrame:(CGRect)frame
{
    if(self = [super initWithFrame:frame])
    {
        [self makeUI];
        self.backgroundColor = [UIColor groupTableViewBackgroundColor];
    }
    return self;
}



-(void)makeUI
{
    _passwordView = [MTInputPasswordView inputPasswordView];
    _titleLable = [UILabel new];
    [self addSubview:_passwordView];
    [self addSubview:_titleLable];
    _titleLable.textColor = [UIColor blackColor];
    _titleLable.font = [UIFont systemFontOfSize:14];
    _titleLable.text = @"请输入钱包密码";
    [_titleLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.centerX).offset(0);
        make.top.mas_equalTo(self.mas_top).offset(10);
    }];
    [self.passwordView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.mas_left).offset(10);
        make.right.mas_equalTo(self.mas_right).offset(-10);
        make.top.mas_equalTo(_titleLable.mas_bottom).offset(10);
        make.height.mas_equalTo(@(40));
    }];
}

-(void)show
{
    KLCPopup *newpop = [KLCPopup popupWithContentView:self];
    newpop.showType = KLCPopupShowTypeSlideInFromBottom;
    newpop.dismissType = KLCPopupDismissTypeSlideOutToBottom;
    newpop.maskType = KLCPopupMaskTypeDimmed;
    self.pop = newpop;
    [newpop showAtCenter:CGPointMake(WIDTH/2.0, HEIGHT/2) inView:[[UIApplication sharedApplication].delegate window]];
    [self.passwordView becomeFirstResponder];
}

-(void)dismis{
    [self.passwordView clearPassword];
    [self.pop dismiss:YES];
}

@end
